package com.dream.keigezhushou.Activity.acty.play.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.dream.keigezhushou.Activity.Uiutils.UiUtils;
import com.dream.keigezhushou.Activity.acty.personal.fragment.MyGameAdapter;
import com.dream.keigezhushou.Activity.bean.Image;
import com.dream.keigezhushou.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 *   最热玩法
 */

public class HotGameFragment extends Fragment {

    @BindView(R.id.lv_hot_video)
    ListView lvHotVideo;
    private List<List<Image>> imagesList;

    private String[][] images = new String[][]{
            {"file:///android_asset/img2.jpg", "250", "250"}
            , {"http://img3.douban.com/view/photo/photo/public/p2249526036.jpg", "640", "960"}
            , {"file:///android_asset/img3.jpg", "250", "250"}
            , {"file:///android_asset/img4.jpg", "250", "250"}
            , {"file:///android_asset/img5.jpg", "250", "250"}
            , {"file:///android_asset/img6.jpg", "250", "250"}
            , {"file:///android_asset/img7.jpg", "250", "250"}
            , {"file:///android_asset/img8.jpg", "250", "250"}
            , {"http://img4.douban.com/view/photo/photo/public/p2252689992.jpg", "1280", "800"}
    };

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = UiUtils.inflateView(R.layout.layout_hot_video);

        ButterKnife.bind(this, view);
        initView();

        return view;
    }

    //初始化界面
    protected void initView() {

        initData();
        //ListView创建适配器
        lvHotVideo.setAdapter(new MyGameAdapter(getActivity(), imagesList));
    }

    //初始化数据
    protected void initData() {

        imagesList = new ArrayList<>();
//        ArrayList<Image> singleList=new ArrayList<>();
        //从一到7生成7条朋友圈内容，分别是1~7张图片
        for (int i = 0; i < 7; i++) {
            ArrayList<Image> itemList = new ArrayList<>();
            for (int j = 0; j <= i; j++) {
                itemList.add(new Image(images[j][0], Integer.parseInt(images[j][1]), Integer.parseInt(images[j][2])));
            }
            imagesList.add(itemList);
        }

    }
}
